package com.lsl.facade_pattern.example1.SubSystem;

import java.util.Arrays;


/**
 * 矮人族矿工类
 * 子系统类
 *
 * @author Zed
 * @description
 * @date 2023/1/8 13:27
 */

public abstract class DwarvenMineWorker {

    public void goToSleep() {
        System.out.println(name()+" 准备睡觉.");
    }

    public void wakeUp() {
        System.out.println(name()+" 醒了.");
    }

    public void goHome() {
        System.out.println(name()+" 回家.");
    }

    public void goToMine() {
        System.out.println(name()+" 去了矿场.");
    }

    private void action(Action action) {
        switch (action) {
            case GO_TO_SLEEP:
                goToSleep();
                break;
            case WAKE_UP:
                wakeUp();
                break;
            case GO_HOME:
                goHome();
                break;
            case GO_TO_MINE:
                goToMine();
                break;
            case WORK:
                work();
                break;
            default:
                break;
        }
    }

    /**
     * Perform actions.
     */
    public void action(Action... actions) {
        Arrays.stream(actions).forEach(this::action);
    }

    public abstract void work();

    public abstract String name();

    public enum Action {
        GO_TO_SLEEP, WAKE_UP, GO_HOME, GO_TO_MINE, WORK
    }
}
